const { defineConfig } = require('@vue/cli-service');
const crypto = require('crypto-browserify');
const stream = require('stream-browserify');
const buffer = require('buffer');
const assert = require('assert');
const http = require('stream-http');
const https = require('https-browserify');
const os = require('os-browserify/browser');
const url = require('url');
const webpack = require('webpack');

module.exports = defineConfig({
  transpileDependencies: true,
  devServer: {
    client: {
      overlay: false // 编译错误时，取消全屏覆盖（建议关掉）
    }
  },
  configureWebpack: {
    resolve: {
      fallback: {
        "crypto": require.resolve("crypto-browserify"),
  
        "stream": require.resolve("stream-browserify"),
        "buffer": require.resolve("buffer"),
        "assert": require.resolve("assert"),
        "http": require.resolve("stream-http"),
        "https": require.resolve("https-browserify"),
        "os": require.resolve("os-browserify/browser"),
        "process": require.resolve("process/browser"),
        "url": require.resolve("url")
      }
    },
    plugins: [
      new (require('webpack')).ProvidePlugin({
        process: 'process/browser', // 提供process全局变量
      }),
    ],
  }
});